//
//  RecordDetailController.m
//  Marketing
//
//  Created by Hanen 3G 01 on 16/3/8.
//  Copyright © 2016年 Hanen 3G 01. All rights reserved.
//

#import "RecordDetailController.h"
#import "MyTextView.h"
#import "ShowImageController.h"

#define SectionbackH  15.0f
@interface RecordDetailController ()<UITextViewDelegate>
{
    CGFloat    topSpace ;
//    UITableView   *_scrollView;
    UIScrollView  * _scrollView;
    //类型
    UIView        *_typeView;
    UILabel       *_typeTitle;
    UILabel       *_typeLabel;
    
    //标题 小结 计划
    UIView        *_workSummaryView;
    UILabel       *_workTitleLabel;
    UILabel       *_workTitle;
    UILabel       *_workSumlabel;
    UITextView       *_workSum;
    UILabel       *_workPlaneLabel;
    UITextView       *_workPlan;
    CGFloat        lastY;//btn
    
    
    UIView       *_workRecordView;
    UILabel      *_recordLabel;
    UILabel      *_recordContentLabel;
    MyTextView  *_textView;
//    UIButton     *_recordBtn;
    UIButton  *_showRecordPic;
    
    
     NSDictionary  *_dataDict;
    UIView      *_bottomView;
    UILabel     *_titleLabel;
    UIImageView    *_addPersonsBtn;
    
}
@end

@implementation RecordDetailController
- (void)viewDidLoad
{
    [super viewDidLoad];
    if (IPhone4S) {
        topSpace = [UIView getWidth:8.0f];
    }else{
        topSpace = [UIView getWidth:10.0f];
    }
    self.automaticallyAdjustsScrollViewInsets = NO;
    self.navigationItem.leftBarButtonItem = [ViewTool getBarButtonItemWithTarget:self WithAction:@selector(popViewcontroll)];
    self.view.backgroundColor = graySectionColor;
    self.navigationItem.titleView = [ViewTool getNavigitionTitleLabel:@"日志详情"] ;
    [self creatScrollView];
    [self creatTypeView];
    [self creatWorkSummaryView];
    [self creatRecordView];
    [self drawBottomView];
    
    [self initData];
}
- (void)initData
{
    NSDictionary *dict = @{@"token" : TOKEN,@"uid" : @(UID),@"wid": @(self.recId)};
//        NSLog(@"%d",self.recId);
        [SVProgressHUD show];
    [DataTool sendGetWithUrl:RECORD_DETAIL_URL parameters:dict success:^(id data) {
            [SVProgressHUD dismiss];
        id backData = CRMJsonParserWithData(data);
        if ([backData[@"code"] intValue] == 100) {
            NSLog(@"%@",backData);
            _dataDict = [DataTool changeType:backData];
            [self useData];
        }else{
            [self.view makeToast:backData[@"message"]];
        }
      
    } fail:^(NSError *error) {
            [SVProgressHUD dismiss];
        NSLog(@"%@",error);
    }];
}
- (void)useData
{
    int type = [_dataDict[@"working"][@"type"] intValue];
    if (type == 1) {
        _typeLabel.text = @"日报";
    }else if (type == 2){
        _typeLabel.text = @"周报";
    }else{
        _typeLabel.text = @"月报";
    }
    NSString * plan = _dataDict[@"working"][@"plan"];
    _workPlan.text = plan;
    
    NSString * remark = _dataDict[@"working"][@"remark"];
    _textView.text = remark;
    
    NSString * topic = _dataDict[@"working"][@"topic"];
    _workTitle.text = topic;
    
    NSString  * content = _dataDict[@"working"][@"content"];
    _workSum.text = content;
    
    NSString *imagePath = [NSString stringWithFormat:@"%@%@",LoadImageUrl,_dataDict[@"working"][@"img"]];
    NSLog(@"imagePath %@",imagePath);
    [_showRecordPic sd_setImageWithURL:[NSURL URLWithString:imagePath] forState:UIControlStateNormal];
    //管理员查看日志接收人 就是自己啊
//#warning 非管理员可以查看的话 就得用返回的数据中的 头像
    [_addPersonsBtn sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",LoadImageUrl,_dataDict[@"dealuserlogo"]]] placeholderImage:nil];
    
}

- (void)creatScrollView
{
//     _scrollView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, KSCreenW, KSCreenH - 64 )];
//    _scrollView.separatorStyle = UITableViewCellSeparatorStyleNone;
   _scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, KSCreenW, KSCreenH - 64 )];
    _scrollView.backgroundColor= graySectionColor;
//    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleScrolltap:)];
//    [_scrollView addGestureRecognizer:tap];
    
    //    UIView *vi = [[UIView alloc] initWithFrame:CGRectMake(0, 50, KSCreenW, 200)];
    //    [_scrollView addSubview:vi];
    //    vi.backgroundColor = [UIColor orangeColor];
    
    NSLog(@"%@",NSStringFromCGRect(_scrollView.frame));
    //    _scrollView.contentSize = CGSizeMake(0, 700);
    //    _scrollView.backgroundColor = [UIColor cyanColor];
    [self.view addSubview:_scrollView];
    
    
}
- (void)creatTypeView
{
    
//    _typeView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, KSCreenW, [UIView getWidth:70])];
////    NSLog(@"%@",NSStringFromCGRect(_typeView.frame));
//        _typeView.backgroundColor = [UIColor whiteColor];
//    [_scrollView addSubview:_typeView];
    
    
//    _typeTitle = [ViewTool getLabelWith:CGRectMake(2 * topSpace, topSpace, 100, 15) WithTitle:@"报表类型" WithFontSize:14.0f WithTitleColor:grayFontColor WithTextAlignment:NSTextAlignmentLeft];
//    [_typeView addSubview:_typeTitle];

//    CGFloat btnW = [UIView getWidth: 30];
//    CGFloat btnH = [UIView getWidth:20];
//    _typeLabel = [ViewTool getLabelWith:CGRectMake(_typeTitle.x, _typeTitle.maxY + topSpace, btnW, btnH) WithTitle:@".." WithFontSize:15.0f WithTitleColor:blackFontColor WithTextAlignment:NSTextAlignmentCenter];
//    _typeLabel.layer.cornerRadius = 10.0f;
//    _typeLabel.layer.masksToBounds = YES;
//    _typeLabel.layer.borderColor = grayLineColor.CGColor;
//    _typeLabel.layer.borderWidth = 1;
//    [_typeView addSubview:_typeLabel];
    
//    UIView *grayView = [[UIView alloc] initWithFrame:CGRectMake(0, _typeLabel.maxY + topSpace, KSCreenW, [UIView getWidth:15.0f])];
//    grayView.backgroundColor = graySectionColor;
//    [_typeView addSubview:grayView];
//    
//    _typeView.frame = CGRectMake(0, 0,KSCreenW, grayView.maxY);
    
    
    _typeView = [[UIView alloc] initWithFrame:CGRectMake(0, 50, KSCreenW, [UIView getWidth:70])];
    NSLog(@"%@",NSStringFromCGRect(_typeView.frame));
    _typeView.backgroundColor = [UIColor whiteColor];
    [_scrollView addSubview:_typeView];
    
    UIView *grayView = [ViewTool getLineViewWith:CGRectMake(0, 0, KSCreenW, 15.0f) withBackgroudColor:graySectionColor];
//    grayView.layer.borderColor = grayLineColor.CGColor;
//    grayView.layer.borderWidth = 1;
    [_typeView addSubview:grayView];
    
    UIView *ine =  [ViewTool getLineViewWith:CGRectMake(0,grayView.height, KSCreenW, 1) withBackgroudColor:grayLineColor];
    [grayView addSubview:ine];
    
    _typeTitle = [ViewTool getLabelWith:CGRectMake( topSpace, grayView.maxY + 0.5 *topSpace, 80, 30.0f) WithTitle:@"报表类型" WithFontSize:15.0f WithTitleColor:grayFontColor WithTextAlignment:NSTextAlignmentLeft];
    [_typeView addSubview:_typeTitle];
    
    CGFloat btnW = 50;
    CGFloat btnH = 30;
    _typeLabel = [ViewTool getLabelWith:CGRectMake(_typeTitle.maxX + topSpace, grayView.maxY + 0.5 * topSpace, btnW, btnH) WithTitle:@".." WithFontSize:15.0f WithTitleColor:[UIColor whiteColor] WithTextAlignment:NSTextAlignmentCenter];
    //CGRectMake(_typeTitle.maxX + topSpace, _typeTitle.y + topSpace, btnW, btnH)
//    _typeLabel.layer.cornerRadius = 10.0f;
//    _typeLabel.layer.masksToBounds = YES;
    _typeLabel.layer.borderWidth = 0.8f;
    _typeLabel.layer.borderColor = grayLineColor.CGColor;
//    _typeLabel.layer.borderWidth = 1;
    _typeLabel.backgroundColor = NavBackColor;
    [_typeView addSubview:_typeLabel];
    
//    NSArray * titleArr = @[@"日报",@"周报",@"月报"];
//    CGFloat btnW = 50;
//    CGFloat btnH = 30;
//    for (int i = 0; i < titleArr.count; i ++) {
//        
//        UIButton * btn = [[UIButton alloc] initWithFrame:CGRectMake(_typeLable.maxX + 5 + (i * (btnW + 2 *topSpace)), grayView.maxY + topSpace, btnW, btnH)];
//        if (i == 0) {
//            btn.selected = YES;
//            _lastBtn = btn;
//            [btn setBackgroundColor:NavBackColor];
//            [btn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
//        }else{
//            btn.selected = NO;
//            [btn setBackgroundColor:[UIColor whiteColor]];
//            [btn setTitleColor:blackFontColor forState:UIControlStateNormal];
//        }
//        btn.titleLabel.font = [UIFont systemFontOfSize:14.0f];
//        //        CGRect rect = CGRectMake(0, 0, btnW, btnH);
//        //        [btn setBackgroundImage:[ViewTool getImageFromColor:blueFontColor WithRect:rect] forState:UIControlStateSelected];
//        //        [btn setBackgroundImage:[ViewTool getImageFromColor:[UIColor redColor] WithRect:btn.frame] forState:UIControlStateNormal];
//        //        [btn setBackgroundColor:blueFontColor];
//        [btn setTitle:titleArr[i] forState:UIControlStateNormal];
//        //        [btn setTitleColor:blackFontColor forState:UIControlStateNormal];
//        //        [btn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
//        //        btn.layer.cornerRadius = 10.0f;
//        btn.layer.borderWidth = 0.8;
//        btn.layer.borderColor = grayLineColor.CGColor;
//        [btn addTarget:self action:@selector(chooseType:) forControlEvents:UIControlEventTouchUpInside];
//        [_typeView addSubview:btn];
//        btn.tag = 300 + i;
//        //        if(i == 2){
//        //            lastY = btn.maxY;
//        //        }
//        
//    }
    
    UIView *grayView2 = [[UIView alloc] initWithFrame:CGRectMake(0, _typeTitle.maxY + 0.5 * topSpace, KSCreenW, SectionbackH)];
    grayView2.backgroundColor = graySectionColor;
    grayView2.layer.borderColor = grayLineColor.CGColor;
    grayView2.layer.borderWidth = 1;
    [_typeView addSubview:grayView2];
    
    _typeView.frame = CGRectMake(0, 0,KSCreenW, grayView2.maxY);
}

- (void)creatWorkSummaryView
{
//    _workSummaryView = [[UIView alloc] initWithFrame:CGRectMake(0, _typeView.maxY, KSCreenW, 200)];
//    //    _workSummaryView.backgroundColor = [UIColor greenColor];
//    [_scrollView addSubview:_workSummaryView];
//    
//    _workTitleLabel = [ViewTool getLabelWith:CGRectMake(2 * topSpace, topSpace, 100, 15) WithTitle:@"工作标题" WithFontSize:14.0f WithTitleColor:grayFontColor WithTextAlignment:NSTextAlignmentLeft];
//    [_workSummaryView addSubview:_workTitleLabel];
//    
//    _workTitle = [[UILabel alloc] initWithFrame:CGRectMake(_workTitleLabel.maxX + topSpace, _workTitleLabel.y, KSCreenW - topSpace - _workTitleLabel.maxX, 20)];
//    _workTitle.textColor = blackFontColor;
//    [_workSummaryView addSubview:_workTitleLabel];
//    _workTitle.font = [UIView getFontWithSize:15.0f];
//    _workTitle.text = @"....";
//    [_workSummaryView addSubview:_workTitle];
//    
////    UIView *line1 = [ViewTool getLineViewWith:CGRectMake(_workTitleLabel.x, _workTitle.maxY + topSpace, KSCreenW - 4 * topSpace, 1) withBackgroudColor:grayLineColor];
////    [_workSummaryView addSubview:line1];
//    
//    
////    _workSumlabel = [ViewTool getLabelWith:CGRectMake(2 * topSpace, line1.maxY + topSpace, 100, 15) WithTitle:@"工作小结" WithFontSize:14.0f WithTitleColor:grayFontColor WithTextAlignment:NSTextAlignmentLeft];
////    [_workSummaryView addSubview:_workSumlabel];
//    
//    _workSum = [[UILabel alloc] initWithFrame:CGRectMake(_workTitleLabel.x, _workSumlabel.maxY + topSpace, KSCreenW - 4 * topSpace, 20)];
//    [_workSummaryView addSubview:_workSum];
//    _workSum.font = [UIView getFontWithSize:15.0f];
//    _workSum.text = @"....";
//    
////    UIView *line2 = [ViewTool getLineViewWith:CGRectMake(_workTitleLabel.x, _workSum.maxY + topSpace, KSCreenW - 4 * topSpace, 1) withBackgroudColor:grayLineColor];
////    [_workSummaryView addSubview:line2];
//    
//    
//    _workPlaneLabel = [ViewTool getLabelWith:CGRectMake(2 * topSpace, line2.maxY + topSpace, 100, 15) WithTitle:@"工作计划" WithFontSize:14.0f WithTitleColor:grayFontColor WithTextAlignment:NSTextAlignmentLeft];
//    [_workSummaryView addSubview:_workPlaneLabel];
//    
//    _workPlan = [[UILabel alloc] initWithFrame:CGRectMake(_workTitleLabel.x, _workPlaneLabel.maxY + topSpace, KSCreenW - 4 * topSpace, 20)];
//    
//    [_workSummaryView addSubview:_workPlan];
//    _workPlan.font = [UIView getFontWithSize:15.0f];
//    _workPlan.text = @"....";
//    
//
//    UIView *grayView1 = [[UIView alloc] initWithFrame:CGRectMake(0, _workPlan.maxY + topSpace, KSCreenW, [UIView getWidth:15.0f])];
//    grayView1.backgroundColor = graySectionColor;
//    [_workSummaryView addSubview:grayView1];
    
    //    CGRect rect = [grayView1 convertRect:grayView1.frame toView:_scrollView];
    
//    _workSummaryView.frame = CGRectMake(0, _typeView.maxY,KSCreenW, grayView1.maxY );
    
    //////
    _workSummaryView = [[UIView alloc] initWithFrame:CGRectMake(0, _typeView.maxY, KSCreenW, 200)];
    _workSummaryView.backgroundColor = [UIColor whiteColor];
    [_scrollView addSubview:_workSummaryView];
    
    _workTitleLabel = [ViewTool getLabelWith:CGRectMake( topSpace, 0, 80.0f, 40.0f) WithTitle:@"工作标题" WithFontSize:15.0f WithTitleColor:lightGrayFontColor WithTextAlignment:NSTextAlignmentLeft];
    [_workSummaryView addSubview:_workTitleLabel];
    
    _workTitle = [[UILabel alloc] initWithFrame:CGRectMake(_workTitleLabel.maxX + topSpace, _workTitleLabel.height / 2.0f - 20, KSCreenW - topSpace - _workTitleLabel.maxX, 40)];
    _workTitle.font = [UIFont systemFontOfSize:15.0f];
    _workTitle.numberOfLines = 0;
//    _workTitle = [[UITextView alloc ]initWithFrame:CGRectMake(_workTitleLabel.maxX + topSpace, _workTitleLabel.y, KSCreenW - topSpace - _workTitleLabel.maxX, 20)];
    _workTitle.textColor = blackFontColor;
//    _workTitle.numberOfLines = 0;

    [_workSummaryView addSubview:_workTitleLabel];
    _workTitle.text = @"....";
    [_workSummaryView addSubview:_workTitle];

    
    UIView *line1 = [ViewTool getLineViewWith:CGRectMake(_workTitleLabel.x, _workTitleLabel.maxY , KSCreenW - _workTitleLabel.x, 1) withBackgroudColor:grayLineColor];
    [_workSummaryView addSubview:line1];
    
    
    _workSumlabel = [ViewTool getLabelWith:CGRectMake( topSpace, line1.maxY + topSpace, 80.0f, 20.0f) WithTitle:@"工作小结" WithFontSize:15.0f WithTitleColor:lightGrayFontColor WithTextAlignment:NSTextAlignmentLeft];
    [_workSummaryView addSubview:_workSumlabel];
    
//    _workSum = [[UILabel alloc] initWithFrame:CGRectMake(_workTitleLabel.maxX + topSpace, _workSumlabel.y - 8, KSCreenW - 2 * topSpace, 80.0f)];
    _workSum = [[UITextView alloc] initWithFrame:CGRectMake(_workTitleLabel.maxX + topSpace - 5, _workSumlabel.y - 8, KSCreenW - 2 * topSpace - _workTitleLabel.maxX, 80.0f)];
    _workSum.editable = NO;
//    _workSum.backgroundColor = NavBackColor;
    [_workSummaryView addSubview:_workSum];
    _workSum.font = [UIFont systemFontOfSize:15.0f];
    _workSum.text = @"....";
    
    
    UIView *line2 = [ViewTool getLineViewWith:CGRectMake(_workTitleLabel.x, _workSum.maxY + topSpace / 2.0, KSCreenW - 2 * topSpace, 1) withBackgroudColor:grayLineColor];
    [_workSummaryView addSubview:line2];
    
    
    _workPlaneLabel = [ViewTool getLabelWith:CGRectMake( topSpace, line2.maxY + topSpace, 100, 20.0f) WithTitle:@"工作计划" WithFontSize:15.0f WithTitleColor:lightGrayFontColor WithTextAlignment:NSTextAlignmentLeft];
    [_workSummaryView addSubview:_workPlaneLabel];
    
//    _workPlan = [ViewTool getLabelWith:CGRectMake(_workTitleLabel.maxX + topSpace, _workPlaneLabel.y - 8, KSCreenW - 2 * topSpace, 80.0f) WithTitle:@"" WithFontSize:14.0f WithTitleColor:grayFontColor WithTextAlignment:NSTextAlignmentLeft];
    _workPlan = [[UITextView alloc] initWithFrame:CGRectMake(_workTitleLabel.maxX + topSpace - 5, _workPlaneLabel.y - 8, KSCreenW - 2 * topSpace - _workTitleLabel.maxX, 80.0f)];
    _workPlan.editable  = NO;
    _workPlan.textColor = blackFontColor;
    _workPlan.font = [UIFont systemFontOfSize:15.0f];
    [_workSummaryView addSubview:_workPlan];
    


    
    
    UIView *grayView1 = [[UIView alloc] initWithFrame:CGRectMake(0, _workPlan.maxY + topSpace / 2.0, KSCreenW, SectionbackH)];
    grayView1.backgroundColor = graySectionColor;
    grayView1.layer.borderColor = grayLineColor.CGColor;
    grayView1.layer.borderWidth = 1;
    [_workSummaryView addSubview:grayView1];

    _workSummaryView.frame = CGRectMake(0, _typeView.maxY,KSCreenW, grayView1.maxY );
 

}


- (void)creatRecordView
{
//    _workRecordView = [[UIView alloc] initWithFrame:CGRectMake(0, _workSummaryView.maxY, KSCreenW, [UIView getHeight:130])];
//    //    _workRecordView.backgroundColor = [UIColor redColor];
//    [_scrollView addSubview:_workRecordView];
//    
//    //    [UIColor colorWithRed:162 / 255 green:162 / 255 blue:162 / 255 alpha:1];
//    _recordLabel = [ViewTool getLabelWith:CGRectMake(2 * topSpace,2 * topSpace, 200, 15) WithTitle:@"备注" WithFontSize:14.0 WithTitleColor:grayFontColor WithTextAlignment:NSTextAlignmentLeft];
//    [_workRecordView addSubview:_recordLabel];
//    
//    _recordContentLabel = [[UILabel alloc] initWithFrame:CGRectMake(2 * topSpace, _recordLabel.maxY + 2, KSCreenW - 4 * topSpace, [UIView getHeight:50])];
//    
//    //    _textView.layer.borderWidth = 0.5;
//    //    _textView.layer.borderColor = [UIColor colorWithWhite:0.8 alpha:0.8].CGColor;
//    _recordContentLabel.backgroundColor = [UIColor whiteColor];
//    _recordContentLabel.textColor = [UIColor colorWithWhite:0.3 alpha:1];
//    _recordContentLabel.numberOfLines = 0;
//    _recordContentLabel.font = [UIView getFontWithSize:15.0f];
//    [_workRecordView addSubview:_recordContentLabel];
    
    
//    _recordBtn = [[UIButton alloc] initWithFrame:CGRectMake(_textView.x, _textView.maxY + topSpace, [UIView getWidth:50], [UIView getWidth:50])];
//    [_recordBtn addTarget:self action:@selector(takePic:) forControlEvents:UIControlEventTouchUpInside];
//    [_recordBtn setImage:[UIImage imageNamed:@"相机star"] forState:UIControlStateNormal];
//    //    _takePictureBtn.backgroundColor = [UIColor orangeColor];
//    [_workRecordView addSubview:_recordBtn];
    
//    _showRecordPic = [[UIImageView alloc] initWithFrame:CGRectMake(_recordContentLabel.x, _recordContentLabel.maxY + topSpace,  [UIView getWidth:50], [UIView getWidth:50])];
////    _showRecordPic.backgroundColor = [UIColor redColor];
//    [_workRecordView addSubview:_showRecordPic];
    
    
//    UIView * lighGrayView2 = [[UIView alloc] initWithFrame:CGRectMake(0, _showRecordPic.maxY + 2 * topSpace, KSCreenW, [UIView getHeight:20])];
//    lighGrayView2.backgroundColor = graySectionColor;
//    [_workRecordView addSubview:lighGrayView2];
//    
//    _workRecordView.frame = CGRectMake(0, _workSummaryView.maxY, KSCreenW, lighGrayView2.maxY);
 
    ///////
    _workRecordView = [[UIView alloc] initWithFrame:CGRectMake(0, _workSummaryView.maxY, KSCreenW, [UIView getHeight:100])];
    _workRecordView.backgroundColor = [UIColor whiteColor];
    [_scrollView addSubview:_workRecordView];
    
    //    [UIColor colorWithRed:162 / 255 green:162 / 255 blue:162 / 255 alpha:1];
    _recordLabel = [ViewTool getLabelWith:CGRectMake( topSpace, topSpace, 80, 15) WithTitle:@"备注" WithFontSize:15.0 WithTitleColor:lightGrayFontColor WithTextAlignment:NSTextAlignmentLeft];
    [_workRecordView addSubview:_recordLabel];
    
    _textView = [[MyTextView alloc] initWithFrame:CGRectMake( _recordLabel.maxX + topSpace - 5, _recordLabel.y - 8, KSCreenW - 2 * topSpace - _recordLabel.maxX, [UIView getHeight:70])];
    _textView.textColor = blackFontColor;
    _textView.delegate = self;
    //    _textView.layer.borderWidth = 0.5;
    //    _textView.layer.borderColor = [UIColor colorWithWhite:0.8 alpha:0.8].CGColor;
    _textView.backgroundColor = [UIColor whiteColor];
//    _textView.textColor = blackFontColor;
//    _textView.placehoderColor = placeholderGrayFontColor;
//    _textView.placehoder = @"请填写备注";
    _textView.editable = NO;
    _textView.font = [UIFont systemFontOfSize:16.0f];
    [_workRecordView addSubview:_textView];
    
    _showRecordPic = [[UIButton alloc] initWithFrame:CGRectMake(topSpace, _textView.maxY + topSpace,50.0f, 50.0)];
    [_showRecordPic addTarget:self action:@selector(showDetailPic) forControlEvents:UIControlEventTouchUpInside];
//        _showRecordPic.backgroundColor = NavBackColor;
    [_workRecordView addSubview:_showRecordPic];
    
//    _recordBtn = [[UIButton alloc] initWithFrame:CGRectMake(_showRecordPic.maxX + topSpace * 0.6, _showRecordPic.y, _showRecordPic.height, _showRecordPic.height)];
//    [_recordBtn addTarget:self action:@selector(takePic:) forControlEvents:UIControlEventTouchUpInside];
//    [_recordBtn setImage:[UIImage imageNamed:@"HY_list_btn_add_pic_normal"] forState:UIControlStateNormal];
//    [_recordBtn setImage:[UIImage imageNamed:@"HY_list_btn_add_pic_pressed"] forState:UIControlStateSelected];
//    //    _takePictureBtn.backgroundColor = [UIColor orangeColor];
//    [_workRecordView addSubview:_recordBtn];
    
    
    
    
    UIView * lighGrayView2 = [[UIView alloc] initWithFrame:CGRectMake(0, _showRecordPic.maxY + 2 * topSpace, KSCreenW, SectionbackH)];
    lighGrayView2.backgroundColor = graySectionColor;
    lighGrayView2.layer.borderColor = grayLineColor.CGColor;
    lighGrayView2.layer.borderWidth = 1;
    [_workRecordView addSubview:lighGrayView2];
    
    _workRecordView.frame = CGRectMake(0, _workSummaryView.maxY, KSCreenW, lighGrayView2.maxY);
}
- (void)showDetailPic
{
    ShowImageController *showVC = [[ShowImageController alloc] init];
    showVC.imageUrl = [NSString stringWithFormat:@"%@%@",LoadImageUrl,_dataDict[@"working"][@"img"]];
    [self.navigationController pushViewController:showVC animated:YES];
}
- (void)drawBottomView
{
    //sdf
//    _bottomView = [[UIView alloc] initWithFrame:CGRectMake(0, _workRecordView.maxY, KSCreenW, [UIView getHeight:40])];
//    _bottomView.backgroundColor = [UIColor whiteColor];
////    [_scrollView addSubview:_bottomView];
    
//    _titleLabel = [ViewTool getLabelWith:CGRectMake(2 * topSpace, topSpace, 200, 15.0f) WithTitle:@"日志接收人" WithFontSize:14.0 WithTitleColor:lightGrayFontColor WithTextAlignment:NSTextAlignmentLeft];
////    [_bottomView addSubview:_titleLabel];
    
//    _addPersonsBtn = [[UIImageView alloc] initWithFrame:[UIView getRectWithX:_titleLabel.x Y:_titleLabel.maxY width:[UIView getWidth:25] andHeight:[UIView getWidth:25]]];
////    [_addPersonsBtn setImage:[UIImage imageNamed:@"添加人员"] forState:UIControlStateNormal];
//    _addPersonsBtn.layer.cornerRadius = _addPersonsBtn.width / 2.0;
//    _addPersonsBtn.layer.masksToBounds = YES;
////    _addPersonsBtn.backgroundColor = [UIColor lightGrayColor];
////    [_addPersonsBtn addTarget:self action:@selector(addPerson2:) forControlEvents:UIControlEventTouchUpInside];
//    [_bottomView addSubview:_addPersonsBtn];
//    _bottomView.frame = CGRectMake(0, _workRecordView.maxY, KSCreenW, _addPersonsBtn.maxY +  topSpace);
//    NSLog(@"%f,%f",_bottomView.maxY + 64,KSCreenH - TabbarH);
 
    /////
    _bottomView = [[UIView alloc] initWithFrame:CGRectMake(0, _workRecordView.maxY, KSCreenW, [UIView getHeight:60])];
    _bottomView.backgroundColor = [UIColor whiteColor];
//     _bottomView.backgroundColor = NavBackColor;
    [_scrollView addSubview:_bottomView];
    
    _titleLabel = [ViewTool getLabelWith:CGRectMake( topSpace, topSpace, 80, _bottomView.height -2 * topSpace) WithTitle:@"日志接收人" WithFontSize:14.0 WithTitleColor:lightGrayFontColor WithTextAlignment:NSTextAlignmentLeft];
    [_bottomView addSubview:_titleLabel];
    
    
    _addPersonsBtn = [[UIImageView alloc] initWithFrame:CGRectMake(_titleLabel.maxX + topSpace, topSpace, _bottomView.height - 2 * topSpace, _bottomView.height - 2 * topSpace)];
    //    [_addPersonsBtn setImage:[UIImage imageNamed:@"添加人员"] forState:UIControlStateNormal];
    _addPersonsBtn.layer.cornerRadius = _addPersonsBtn.width / 2.0;
    _addPersonsBtn.layer.masksToBounds = YES;
    //    _addPersonsBtn.backgroundColor = [UIColor lightGrayColor];
    //    [_addPersonsBtn addTarget:self action:@selector(addPerson2:) forControlEvents:UIControlEventTouchUpInside];
    [_bottomView addSubview:_addPersonsBtn];
    
    
//    _addPersonsBtn = [[UIButton alloc] initWithFrame:CGRectMake(_titleLabel.maxX + topSpace, topSpace, _bottomView.height - 2 * topSpace, _bottomView.height - 2 * topSpace)];
//    [_addPersonsBtn setImage:[UIImage imageNamed:@"添加人员"] forState:UIControlStateNormal];
//    _addPersonsBtn.layer.cornerRadius = _addPersonsBtn.width / 2.0;
//    _addPersonsBtn.layer.masksToBounds = YES;
//    _addPersonsBtn.backgroundColor = [UIColor lightGrayColor];
//    [_addPersonsBtn addTarget:self action:@selector(addPerson2:) forControlEvents:UIControlEventTouchUpInside];
//    _isChoosePerson = NO;//开始的时候是未选择的
//    [_bottomView addSubview:_addPersonsBtn];
    
    _bottomView.frame = CGRectMake(0, _workRecordView.maxY, KSCreenW, _addPersonsBtn.maxY +  topSpace);
//    _bottomView.backgroundColor = NavBackColor;
    //    NSLog(@"%f,%f",_bottomView.maxY + 64,KSCreenH - TabbarH);
    //    if (_bottomView.maxY + 64 > KSCreenH - TabbarH) {
    //        _scrollView.contentSize = CGSizeMake(0, _bottomView.maxY + TabbarH);
    //    }else{
    //        _scrollView.contentSize = CGSizeMake(0, 0);
    //    }
    UIView *line = [ViewTool getLineViewWith:CGRectMake(0, _bottomView.height - 1, KSCreenW, 1) withBackgroudColor:grayLineColor];
    [_bottomView addSubview:line];
    
    
//    UILabel *label = [ViewTool getLabelWith:CGRectMake(_titleLabel.x, _bottomView.maxY + 5, 100, 20.0f) WithTitle:@"点击头像删除" WithFontSize:13.0f WithTitleColor:grayFontColor WithTextAlignment:NSTextAlignmentLeft];
//    [_scrollView addSubview:label];
    
    
    if (_bottomView.maxY < KSCreenH - 64) {
        CGFloat diff = KSCreenH - 64 - _bottomView.maxY;
        UIView *vie = [ViewTool getLineViewWith:CGRectMake( 0, _bottomView.maxY, KSCreenW, diff) withBackgroudColor:graySectionColor];
        [_scrollView addSubview:vie];
        _scrollView.contentSize = CGSizeMake(KSCreenW, vie.maxY+ 30);
    }else{
         _scrollView.contentSize = CGSizeMake(0, _bottomView.maxY + 20);
    }
//    _scrollView.backgroundColor = greenBackColor;
//    _scrollView.contentSize = CGSizeMake(0, _bottomView.maxY - 50);
}



- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    self.navigationController.navigationBarHidden = NO;
    self.tabBarController.hidesBottomBarWhenPushed = YES;
}

- (void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];
    self.tabBarController.hidesBottomBarWhenPushed = NO;
}
- (void)popViewcontroll
{
    [self.navigationController popViewControllerAnimated:YES];
}

@end
